﻿@model TestOnlineProject.Models.Entities.AccountModel
@{
    ViewBag.Title = "LogIn";
    Layout = "~/Views/Shared/_LogIn.cshtml";
}
@{
    if (!String.IsNullOrEmpty(ViewBag.Msg))
    {
    <script>        alert("@ViewBag.Msg")</script>
    }
}
<script>
    $(document).ready(function () {
        $("button[name=Forgot]").click(function () {
            var email = document.getElementById("Email").value;
            if (email == "") {
                var div = document.getElementById("ErrorMessage");
                div.innerHTML = "Please enter email and try again!";
                $(div).css("display", "block");
            } else {
                $.ajax({
                    url: "ForgotPassword?email=" + email,
                    success: function (data) {
                        alert(data);
                        window.location.href = window.location.href;
                    }
                });
            }
        });
    });
</script>
<div class="site_map">
    @Html.ActionLink("Home", "Index", "Home") / Login
</div>
<br />
@using (Html.BeginForm())
{
    <div style="width: 330px; margin: auto">
        @if (Html.ViewData.ModelState.Count >= 3)
        {
            <div class="alert alert-error">
                @Html.ValidationSummary(true)
            </div>
        }
        <table class="table table-bordered">
            <tr>
                <td style="width: 80px; text-align: right">
                    Username
                </td>
                <td>
                    @Html.TextBoxFor(model => model.Username, new { })
                    <span class="errorMsg">
                        @Html.ValidationMessageFor(model => model.Username)
                    </span>
                </td>
            </tr>
            <tr>
                <td style="text-align: right">
                    Password
                </td>
                <td>
                    @Html.PasswordFor(model => model.Password, new { })
                    <span class="errorMsg">
                        @Html.ValidationMessageFor(model => model.Password)
                    </span>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td style="border-left-style: none">
                    <input type="submit" class="btn" style="width: 90px" value="Login" />
                    <input type="reset" class="btn" style="width: 90px" value="Reset" />
                    <a href="#ForgotPass" role="link" class="btn btn-link" data-toggle="modal">Forgot your
                        password?</a>
                </td>
            </tr>
        </table>
    </div>
}
<div id="ForgotPass" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div style="padding: 15px">
        <h1 style="text-align: center; font-size: 2.5em">
            Forgot your Password?</h1>
        <p style="padding-bottom: 10px">
            Please enter the email address for your account. A new password will be sent to
            you. Once you have received the new password, you will be able to choose a new password
            for your account.</p>
        <fieldset>
            <label>
                <b>Email Address:</b> <span class="start" style="color: red">(*)</span>
            </label>
            <br />
            <div class="alert alert-error" id="ErrorMessage" style="display: none">
            </div>
            <input type="text" aria-required="true" required="required" id="Email" />
        </fieldset>
        <br />
        <div>
            <button class="btn btn-small btn-primary" name="Forgot">
                Submit</button>
        </div>
    </div>
</div>